#ifndef COOLPOOL_SIMULATION_SIBOBJECTS_BALL_H_
#define COOLPOOL_SIMULATION_SIBOBJECTS_BALL_H_

#include <assert.h>
#include <GL/freeglut.h>
#include <limits.h>
#include <CPMath.h>

#include "BallRenderable.h"
#include "Constants.h"
#include "SimObjectsExceptions.h"
#include "ObjectTypes.h"
#include "RigidBody.h"

namespace coolpool
{
	// Usable ball object with a texture and radius.
	class Ball: public RigidBody
	{
	public:
		Ball(double radius);
		Ball(const Ball & ball);
		void init();

		virtual ~Ball();

		// Overrides:
		virtual Entity * clone() const;
		virtual int getType() const;
		virtual const BoundingCylinder & getBoundingCylinder();
		virtual IRenderable * getRenderable();

		// Getters:
		inline double getCoefficientOfRollingFrictionWith(int type_id)
		{
			coeffs_iterator it = coefficients_of_rolling_friction_.find(type_id);
			return (it != coefficients_of_rolling_friction_.end()) ? it->second : 0.0;
		}
		inline double getRadius() const
		{
			return radius_;
		}
		inline GLuint getTexture() const
		{
			return texture_;
		}

		// Setters:
		inline void setCoefficientOfRollingFrictionFor(double coefficient_of_friction, int type_id)
		{
			coefficients_of_rolling_friction_[type_id] = coefficient_of_friction;
		}
		inline void setTexture(GLuint texture)
		{
			texture_ = texture;
		}

	private:

		BoundingCylinder bounding_cylinder_;
		std::map<int, double> coefficients_of_rolling_friction_;
		double radius_;
		GLuint texture_;
	};
}

#endif
